﻿using System;
using System.Text;
using IAM.Interface.Model;
using IAM.Interface.Model.ENUM;
using IAM.Interface.Common.Context;
using IAM.Interface.DAL.Request.Interface;
using IAM.Interface.IDAL;

namespace IAM.Interface.DAL.Request
{
    /// <summary>
    /// 代理管理
    /// </summary>
    public class DelegationMgnt : AbstractAppType, IDelegationMgnt
    {
        #region 方法
        /// <summary>
        /// 获取可代理模块列表
        /// </summary>
        /// <returns>可以进行代理设置的模块列表</returns>
        public Modules GetModuleList()
        {
            //1.实例化RequestContextModel对象
            RequestContextModel rcm = new RequestContextModel(
                ActionType.DM_GETMODULELIST,
                OperationType.Nullity,
                new NullityObj(),
                (new NullityObj()).GetType(),
                AppType);
            //2.实例化请求端上下文控制对象
            RequestContextControl rcc = new RequestContextControl(rcm);
            //3.发送消息
            string strreturn = rcc.Send();
            //4.接收消息
            object obj = rcc.Incept(strreturn);
            //5.转换通用类的类型
            return (Modules)obj;
        }
        /// <summary>
        /// 获取用户代理信息
        /// </summary>
        /// <param name="accountinfo">人员帐号信息</param>
        /// <returns>代理设置信息列表</returns>
        public AIDelegations GetDelegationInfo(AccountInfo accountinfo)
        {
            //1.实例化RequestContextModel对象
            RequestContextModel rcm = new RequestContextModel(
                ActionType.DM_GETDELEINFO,
                OperationType.Nullity,
                accountinfo,
                accountinfo.GetType(),
                AppType);
            //2.实例化请求端上下文控制对象
            RequestContextControl rcc = new RequestContextControl(rcm);
            //3.发送消息
            string strreturn = rcc.Send();
            //4.接收消息
            object obj = rcc.Incept(strreturn);
            //5.转换通用类的类型
            return (AIDelegations)obj;
        }
        /// <summary>
        /// 设置用户代理信息
        /// </summary>
        /// <param name="aidelegations">用户代理信息</param>
        /// <returns>设置后的用户代理信息</returns>
        public AIDelegations SetDelegationInfo(AIDelegations aidelegations)
        {
            //1.实例化RequestContextModel对象
            RequestContextModel rcm = new RequestContextModel(
                ActionType.DM_SETDELEINFO,
                OperationType.Nullity,
                aidelegations,
                aidelegations.GetType(),
                AppType);
            //2.实例化请求端上下文控制对象
            RequestContextControl rcc = new RequestContextControl(rcm);
            //3.发送消息
            string strreturn = rcc.Send();
            //4.接收消息
            object obj = rcc.Incept(strreturn);
            //5.转换通用类的类型
            return (AIDelegations)obj;
        }
        #endregion
    }
}
